package ru.zombator.taskman.core.dbclient.impl;

import java.util.UUID;

import ru.zombator.taskman.core.domain.Datestamp;
import ru.zombator.taskman.core.domain.IWorkTime;
import ru.zombator.taskman.core.domain.IWorker;

/**
 * Отметка рабочего времени
 * 
 * @see IWorkTime
 * @author nvamelichev
 *
 */
public class WorkTime implements IWorkTime {
	private static final long serialVersionUID = 1L;
	
	private UUID id;
	private IWorker who;
	private byte hours;
	private Datestamp date;

	public WorkTime(UUID id, IWorker who, Datestamp date, byte hours) throws IllegalArgumentException {
		if (hours < 0 || hours > 24) {
			throw new IllegalArgumentException("hours");
		}
		
		this.id = id;
		this.who = who;
		this.date = date;
		this.hours = hours;
	}
	
	@Override
	public Datestamp getDate() {
		return date;
	}

	@Override
	public int getHours() {
		return hours;
	}

	@Override
	public IWorker getWho() {
		return who;
	}

	@Override
	public void setDate(Datestamp newDate) {
		this.date = newDate;
	}

	@Override
	public void setHours(byte hours) throws IllegalArgumentException {
		if (hours < 0 || hours > 24) {
			throw new IllegalArgumentException("hours");
		}
		this.hours = hours;
	}

	@Override
	public void setWho(IWorker who) {
		this.who = who;
	}

	@Override
	public UUID getId() {
		return id;
	}
	
}
